package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.entity.Orders;
import com.sky.vo.OrderDetailsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

@Mapper
public interface OrderMapper {
    /**插入订单*/
    void insertOrder(Orders orders);

/**查询订单*/
    @Select("select * from orders where id = #{id}")
    Orders selectOrderById(Long id);

/**根据userId和支付状态查询订单*/
    Page<OrderDetailsVO> selectOrderByUserId(Long userId, Integer status);

    /**取消订单*/
    @Update("update orders set status = #{status} where user_id = #{userId} and id = #{id}")
    void cancelOrderById(Long id, Long userId, Integer status);

    /**查询总订单数*/
    Integer countByMap(Map map);

    /**营业额*/
    Double sumByMap(Map map);
}
